const { getUuid } = require("./getUuid");
const { fileLog } = require("./log");
const maxTryToGetUuidCount = 100;
class ConnectionMap extends Object {
    add(connection) {
        for (let i = 0; i < maxTryToGetUuidCount; i++) {
            const uuid = getUuid();
            if (!this[uuid]) {
                this[uuid] = connection;
                // connection.uuid = uuid;
                return uuid;
            }
        }

        fileLog("get uuid over max count");
        return null;
    }

    remove(uuid) {
        delete this[uuid];
    }
}

module.exports = {
    ConnectionMap
}